//
//  AppDelegate.m
//  SafPay
//
//  Created by 贺庆博 on 2018/6/19.
//  Copyright © 2018年 ebo. All rights reserved.
//

#import "AppDelegate.h"
#import "CheckViewController.h"
#import "WellCome.h"
#import "HomeViewController.h"
@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [IQKeyboardManager sharedManager].enable = YES;
    [IQKeyboardManager sharedManager].shouldResignOnTouchOutside = YES;
    [self setIsFirst];
    
    if(![AccountTools shared].currentAccount.token){
        
        UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:[[CheckViewController alloc]initWithNibName:@"CheckViewController" bundle:nil]];
        self.window.rootViewController= nav;
        
    }else{
        
        UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:[HomeViewController new]];
        self.window.rootViewController= nav;
        
    }

    [self.window makeKeyAndVisible];
    if([self isFirstStart]){
        
        WellCome *wellCome = [[WellCome alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
        [self.window addSubview:wellCome];
    }
    return YES;
}


- (void)applicationWillResignActive:(UIApplication *)application {
    
}


- (void)applicationDidEnterBackground:(UIApplication *)application {

}


- (void)applicationWillEnterForeground:(UIApplication *)application {

}


- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}


- (void)applicationWillTerminate:(UIApplication *)application {
 
    
}
-(void)setIsFirst{
    
    if(![[NSUserDefaults standardUserDefaults] valueForKey:@"firstLaunch"]){
        [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"firstLaunch"];
        //第一次启动
    }else{
        //不是第一次启动了
        [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"firstLaunch"];
    }
    
    
}
-(BOOL)isFirstStart{
    
    if([[NSUserDefaults standardUserDefaults] boolForKey:@"firstLaunch"]==YES){
        
        return YES;
    }else{
        
        return NO;
    }
}

@end
